Don't ever return BASELINE from gtk_widget_get_halign
authorAlexander Larsson <alexl@redhat.com>
Mon, 16 Sep 2013 10:33:56 +0000 (12:33 +0200)
committerAlexander Larsson <alexl@redhat.com>
Mon, 16 Sep 2013 10:33:56 +0000 (12:33 +0200)
This is the same behaviour as gtk_widget_get_valign, except
we have no gtk_wiget_get_halign_with_baseline, as baselines make
no sense for halign.

Without this some widgets (like e.g. GtkOverlay) crash if you accidentally
set a BASELINE halign.

gtk/gtkwidget.c

index 213a3fe5c370fef52bac92054d742eb68c753a5f..a2e5e3c662a387e29edeaac7bdd3616b8d53e6fd 100644 (file)
@@ -13859,13 +13859,24 @@ gtk_widget_real_get_width_for_height (GtkWidget *widget,
  *
  * Gets the value of the #GtkWidget:halign property.
  *
+ * For backwards compatibility reasons this method will never return
+ * %GTK_ALIGN_BASELINE, but instead it will convert it to
+ * %GTK_ALIGN_FILL. Baselines are not supported for horizontal
+ * alignment.
+ *
  * Returns: the horizontal alignment of @widget
  */
 GtkAlign
 gtk_widget_get_halign (GtkWidget *widget)
 {
+  GtkAlign align;
+
   g_return_val_if_fail (GTK_IS_WIDGET (widget), GTK_ALIGN_FILL);
-  return _gtk_widget_get_aux_info_or_defaults (widget)->halign;
+
+  align = _gtk_widget_get_aux_info_or_defaults (widget)->halign;
+  if (align == GTK_ALIGN_BASELINE)
+    return GTK_ALIGN_FILL;
+  return align;
 }
 
 /**